//
//  MyBookCityView.m
//  悦读
//
//  Created by dllo on 15/5/22.
//  Copyright (c) 2015年 贾建兴. All rights reserved.
//

#import "MyBookCityView.h"

@implementation MyBookCityView
- (void)dealloc
{
    [_nameLabel release];
    [_image release];
    [_authorLabel release];
    [_bookId release];
    [super dealloc];
}

- (instancetype)initWithFrame:(CGRect)frame
{
    if (self = [super initWithFrame:frame]) {
        
        //调用方法创建书城主页面每个小说的视图
        [self createView];

        
    }return self;
}

//创建自定义视图
- (void)createView
{
    // 创建image
    
//    CAPropertyAnimation
//    CAAnimation
//    CAKeyframeAnimation
//    CABasicAnimation
    //    CATransition
    // 上面五个都继承与CAAnimation
//    CAAnimation
//    CATransaction
    [self setBackgroundColor:[UIColor whiteColor]];
    self.image = [[UIImageView alloc]initWithFrame:CGRectMake(0, 0, self.frame.size.width , self.frame.size.height - 30)];
    [self.image setBackgroundColor:[UIColor whiteColor]];//?????????
    [self addSubview:self.image];
    // 创建namelabel
    self.nameLabel = [[UILabel alloc]initWithFrame:CGRectMake(0, self.frame.size.height - 30, self.frame.size.width, 15)];
    self.nameLabel.font = [UIFont systemFontOfSize:10];
    self.nameLabel.textAlignment = 1;
    [self.nameLabel setBackgroundColor:[UIColor whiteColor]];
    [self addSubview:self.nameLabel];
    // 创建authorLabel
    self.authorLabel = [[UILabel alloc]initWithFrame:CGRectMake(0, self.frame.size.height - 15, self.frame.size.width,  15)];
    self.authorLabel.font = [UIFont systemFontOfSize:10];
    self.authorLabel.textAlignment = 1;
    [self.authorLabel setBackgroundColor:[UIColor whiteColor]];
    [self addSubview:self.authorLabel];
    UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(tapAction:)];
    [self addGestureRecognizer:tap];
    [tap release];
    
}


- (void)tapAction:(UITapGestureRecognizer *)tap
{
    // 让代理人在合理的时间干活
    MyBookCityView *bookView = (MyBookCityView *)tap.view;
    [self.delegate pushBookDetailView:bookView.bookId];
    
}

@end
